package org.scirp.ijmis.service.personpaper.impl;

import java.util.List;

import org.scirp.ijmis.dao.personpaper.IResearchFieldOfPersonDAO;
import org.scirp.ijmis.po.personpaper.ResearchFieldOfPerson;
import org.scirp.ijmis.service.personpaper.IResearchFieldOfPersonService;

public class ResearchFieldOfPersonServiceImpl implements IResearchFieldOfPersonService {
	private IResearchFieldOfPersonDAO researchFieldOfPersonDAO;
	


	@Override
	public boolean deleteResearchFieldOfPerson(ResearchFieldOfPerson researchfieldOfPerson) {
		return researchFieldOfPersonDAO.deleteResearchFieldOfPerson(researchfieldOfPerson);
	}

	public boolean deleteResearchFieldOfPersonByPersonId(Long PersonId) {
		return researchFieldOfPersonDAO.deleteResearchFieldOfPersonByPersonId(PersonId);
	}

	@Override
	public boolean saveResearchFieldOfPerson(ResearchFieldOfPerson researchfieldOfPerson) {
		return researchFieldOfPersonDAO.saveResearchFieldOfPerson(researchfieldOfPerson);
	}

	@Override
	public List<ResearchFieldOfPerson> selectAll() {
		return researchFieldOfPersonDAO.selectAll();
	}

	@Override
	public ResearchFieldOfPerson selectById(long id) {
		return researchFieldOfPersonDAO.selectById(id);
	}

	@Override
	public List<ResearchFieldOfPerson> selectByPersonId(long PersonId) {
		return researchFieldOfPersonDAO.selectByPersonId(PersonId);
	}

	public boolean updateResearchFieldOfPerson(ResearchFieldOfPerson researchfieldOfPerson) {
		return researchFieldOfPersonDAO.updateResearchFieldOfPerson(researchfieldOfPerson);
	}
	
	public boolean updatePersonResearchField(Long personId,List<ResearchFieldOfPerson> researchFieldOfPersonList)
	{
		boolean flag=researchFieldOfPersonDAO.deleteResearchFieldOfPersonByPersonId(personId);
		if(flag){
			boolean fla=true;
			for(ResearchFieldOfPerson researchFieldOfPerson:researchFieldOfPersonList){
				if(!researchFieldOfPersonDAO.saveResearchFieldOfPerson(researchFieldOfPerson)){
					fla=false;
				}
			}
			return fla;
		}
		else{
			return false;
		}
		
	}
	
	
	
	
	public IResearchFieldOfPersonDAO getResearchFieldOfPersonDAO() {
		return researchFieldOfPersonDAO;
	}

	public void setResearchFieldOfPersonDAO(IResearchFieldOfPersonDAO researchFieldOfPersonDAO) {
		this.researchFieldOfPersonDAO = researchFieldOfPersonDAO;
	}
}
